﻿Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Xml
Imports System.Reflection


Partial Class 观测事件


    Public 标记 As String
    Public 时间 As String
    Public 测站 As String
    Public 呈像 As String
    Public 温度 As String
    Public 天气 As String
    Public 云量 As String
    Public 太阳方向 As String
    Public 风速 As String
    Public 风向 As String
    Public 道路 As String
    Public 土质 As String
    Public 加密数据 As String


    Public Property 测段 As 测段

    Public Property 数据s As IList(Of 数据) = New List(Of 数据)()

    Public Shared Function Paras(xxNode As XmlNode) As 观测事件

        Dim tmpClass As 观测事件 = New 观测事件()
        Dim nameList As XmlAttributeCollection = xxNode.Attributes

        For Each xxattribute As XmlAttribute In nameList

            Try

                Dim tmpType As Type = tmpClass.GetType()
                Dim tmpP As FieldInfo = tmpType.GetField(xxattribute.Name)
                tmpP.SetValue(tmpClass, xxattribute.Value)
            Catch ex As Exception

            End Try

        Next



        Dim childList As XmlNodeList = xxNode.ChildNodes  '取得row下的子节点集合   
        For Each xxxNode As XmlNode In childList

            If (xxxNode.Name.Equals("数据")) Then
                Dim tmp数据 As 数据 = 数据.Paras(xxxNode)
                tmp数据.观测事件 = tmpClass
                tmpClass.数据s.Add(tmp数据)
            End If
        Next


        Return tmpClass

    End Function
    ''' <summary>
    ''' 获取上下观测点名称
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function getNameUD() As String
        If Val(Me.测站 = 0) Then
            Dim b As 数据 = (From p In Me.数据s Select p).FirstOrDefault()
            If IsNothing(b) Then
                Return ""
            Else
                Return b.点名
            End If
        Else
            Dim b As 数据 = (From p In Me.数据s Select p).FirstOrDefault()
            If IsNothing(b) Then
                Return ""
            Else
                Return b.点名
            End If

        End If
    End Function

    Function gteElevationUD() As String
        Dim b As 数据 = (From p In Me.数据s Select p).FirstOrDefault()
        If IsNothing(b) Then
            Return ""
        Else
            Return b.高差
        End If
    End Function


End Class
